#ifndef MY_FIFO_H
#define MY_FIFO_H

typedef struct _SFIFO{
	U16* pusData;//数据区域
	U32 ulSize;//FIFO数据区的大小
	U32 ulWriteInx;//写索引
	U32 ulReadInx;//读索引
	U32 ulCanReadNumber;//当前有效个数
	U32 ulWantReadNumber;//需要读取个数
	U32 overFlow; //溢出标志，溢出次数
	pthread_mutex_t spinLock;
	pthread_cond_t fifo_cond;
}SFIFO, *PSFIFO;

int SFifoWriteSingle( PSFIFO pSFifo, U16 usData );
int SFifoWrite( PSFIFO pSFifo, U16* pusData, U32 ulWriteNumber );
int SFifoWriteLock( PSFIFO pSFifo, U16* pusData, U32 ulWriteNumber );
int SFifoRead( PSFIFO pSFifo, U16* pusData, U32 ulReadNumber );
int SFifoReadLock( PSFIFO pSFifo, U16* pusData, U32 ulReadNumber );
inline U32 SFifoCanReadNum( PSFIFO pSFifo );
inline U32 SFifoCanWriteNum( PSFIFO pSFifo );
void SFifoClear( PSFIFO pSFifo );
PSFIFO SFifoAlloc( U32 ulSize );
void SFifoFree( PSFIFO psf );

#endif
